#include <boost/functional/hash.hpp>
#include <iostream>
#include <string>
#include "algorithm.h"
#include "week3.h"
#include <time.h>
#include <fstream>
#include <string>

using namespace std;

void testGenrateSubsets(string timeFile,string subsetsFile,int maxSetNum);
int main(){
	//test construct all subsets (week3)
	testGenrateSubsets("generateSubsetsTimeTest.txt","generateSubsets.txt",5);
	

	/*
	//test boost::hash
	boost::hash<std::string> string_hash;
	std::size_t result1=string_hash("hash me");
	std::size_t result2=string_hash(std::string("hash me"));
	std::cout<<result1<<"   "<<result2<<std::endl;
	//test strMatch
	cout<<strMatch(string("hello"),string("lelfaweo"))<<endl;
	system("pause");
	*/
}


void testGenrateSubsets(string timeFile,string subsetsFile,int maxSetNum){
	ofstream osTime(timeFile);
	ofstream osSubsets(subsetsFile);
	osTime.clear();
	osSubsets.clear();
	long beginTime,endTime; 
	for(int i=1;i<=maxSetNum;i++){
		osSubsets<<"all subsets of a set with size:"<<i<<endl;
		beginTime=clock();
		generateSubsets::generate_subsets(i,osSubsets);
		endTime=clock();
		osSubsets<<"-------------------------------"<<endl;
		osTime<<"current set size:"<<i<<endl
			<<"num of subsets:"<<generateSubsets::num<<endl
			<<"time elapsed:"<<(float)(endTime-beginTime)/CLOCKS_PER_SEC<<"seconds"<<endl
			<<"---------------------------------"<<endl;
		generateSubsets::num=0;//reset num
	}
	osTime.close();
	osSubsets.close();
}